package system

import (
	"5title_gin/internal/service/system"
	"5title_gin/pkg/utils/http"
	"github.com/gin-gonic/gin"
)

type RoleAPI struct {
	service *system.RoleService
}

func NewRoleAPI() *RoleAPI {
	return &RoleAPI{
		service: system.NewRoleService(),
	}
}

func (api *RoleAPI) GetRoleList(c *gin.Context) {
	vos, err := api.service.GetRoleList()
	if err != nil {
		http.FailWithMsg("获取角色列表失败", c)
		return
	}
	http.OkWithData(vos, c)
}

func (api *RoleAPI) GetRoleOptions(c *gin.Context) {
	options, err := api.service.GetRoleOptions()
	if err != nil {
		http.Error("获取角色下拉列表失败", err, c)
		return

	}
	http.OkWithData(options, c)
}
